# Maintainer: David Macek <david.macek.0@gmail.com>

_realname=port-scanner
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=1.3
pkgrel=3
pkgdesc="A multi threaded TCP port scanner from SecPoint.com (mingw-w64)"
arch=('any')
url="https://www.secpoint.com/multi-threaded-tcp-port-scanner.html"
license=('BSD')
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc")
source=("https://www.secpoint.com/freetools/threaded-port-scanner-${pkgver}.zip"
        "paths.patch")
sha256sums=('768c595fba7ba7e81da35e1bba1118bf08a1d689c6e419804d2109fc64177436'
            '71d17400c3c00387d7f5ba9b0bfa761b29c3707cf0ff1708c4e1b496686d32e9')

prepare() {
  cd "${srcdir}/threaded-port-scanner-${pkgver}"
  rm -f pathtools.c pathtools.h
  patch -p1 -i "${srcdir}/paths.patch" # also adds -lws2_32
  mkdir -p "${srcdir}/build-${CARCH}"
  cp * "${srcdir}/build-${CARCH}"
}

build() {
  cd "${srcdir}/build-${CARCH}"
  make
}

package() {
  cd "${srcdir}/build-${CARCH}"
  install -Dm755 pscan.exe "${pkgdir}${MINGW_PREFIX}/bin/pscan.exe"
  install -Dm644 oui.txt "${pkgdir}${MINGW_PREFIX}/share/port-scanner/oui.txt"
  install -Dm644 port-numbers.txt "${pkgdir}${MINGW_PREFIX}/share/port-scanner/port-numbers.txt"
}
